import http from '../util/http.js';

export default {

    getCaptcha:()=>{
        return http({
            method:'get',
            url:'api/captcha/base'
        });
    },

    getChartsA:()=>{
      return http({
          method:'get',
          url:'api/charts/chartsA'
      });
    },

    getChartsB:()=>{
        return http({
            method:'get',
            url:'api/charts/chartsB'
        });
    },

    getChartsC:()=>{
        return http({
            method:'get',
            url:'api/charts/chartsC'
        });
    },

    getChartsD:()=>{
        return http({
            method:'get',
            url:'api/charts/chartsD'
        });
    },


    getAdminList:()=>{
      return http({
          method:"get",
          url:"api/buser/list"
      });
    },

    getAdminPage:(page)=>{
        return http({
           method:'get',
           url:'api/buser/page',
           params:page
        });
    },

    deleteAdmin:(id)=>{
      return http({
          method:"delete",
          url:'api/buser/'+id
      });
    },
    addAdmin:(obj)=>{
      return http({
          method:'post',
          url:'api/buser/add',
          data: obj,
          headers: {
              //定义将数据以json的形式传入后台(java)
              'Content-Type': 'application/json'
          }
      });
    },
    editAdmin:(obj)=>{
    return http({
        method:'put',
        url:'api/buser/edit',
        data: obj,
        headers: {
            //定义将数据以json的形式传入后台(java)
            'Content-Type': 'application/json'
        }
    });
},

    /*对商品的数据操作*/
    productGetOne: (id) => {
        return http({url: 'api/product/' + id, method: 'get'});
    },
    productGetPage: async (current, size) => {
        const val = await http({
            url: 'api/product/page', method: 'get',
            params: {current, size}
        });
        //表单数据
        console.log("---------------");
        console.log(val);
        return val;
    },

    productDelete: (id) => {
        http({
            url: "api/product/" + id,
            method: 'delete'
        });
    },
    productEdit: (obj) => {
        console.log(obj);
        return http({
            url: "api/product/",
            method: 'PUT',
            //提交json
            data: obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
    },
}